package com.kerrykidz.filemanagement.controller;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.kerrykidz.common.Constants;
import com.kerrykidz.common.ORDER_CONSTANTS;
import com.kerrykidz.common.PrimaryKeyGenerator;
import com.kerrykidz.common.PrimaryKeyGenerator.BusinessType;
import com.kerrykidz.common.service.ICommonService;
import com.kerrykidz.filemanagement.dao.model.HisCarCareEntity;
import com.kerrykidz.filemanagement.dao.model.HisOrderEntity;
import com.kerrykidz.filemanagement.dao.model.HisTicketEntity;
import com.kerrykidz.filemanagement.dao.model.UserInOutCombEntity;
import com.kerrykidz.filemanagement.dao.model.VipUserEntity;
import com.kerrykidz.filemanagement.service.ISalesService;
import com.kerrykidz.filemanagement.service.IVipService;
import com.kerrykidz.filemanagement.service.impl.VipServiceImpl;
import com.kerrykidz.membership.dao.model.CusGuaEntity;
import com.kerrykidz.membership.dao.model.CusMemClassEntity;
import com.kerrykidz.membership.dao.model.CusMemEntity;
import com.kerrykidz.membership.dao.model.CusMemHisEntity;
import com.kerrykidz.membership.dao.model.CusMemSuspendEntity;
import com.kerrykidz.membership.dao.model.GblCusCReltypeEntity;
import com.kerrykidz.membership.service.IGuaService;
import com.kerrykidz.membership.service.IMemHisService;
import com.kerrykidz.membership.service.IMemberService;
import com.kerrykidz.sales.dao.mapper.PosOrderEntityMapper;
import com.kerrykidz.sales.dao.model.PosOrderEntity;
import com.kerrykidz.sales.dao.model.PosOrderPrdEntity;
import com.kerrykidz.sales.service.IOrderService;
import com.kerrykidz.sales.service.IPaymentService;
import com.kerrykidz.scminvoicing.dao.model.GblScmPrdEntity;
import com.kerrykidz.scminvoicing.service.IScmInvocingProductInfoService;
import com.kerrykidz.system.dao.model.GblCusCCountryEntity;
import com.kerrykidz.system.dao.model.GblSecBranEntity;
import com.kerrykidz.system.dao.model.SecUsrEntity;
import com.kerrykidz.system.dao.model.SysParaEntity;
import com.kerrykidz.system.service.ICusMemClassService;
import com.kerrykidz.system.service.IGblService;
import com.kerrykidz.system.service.ISysBarCodeService;
import com.kerrykidz.system.service.IUserService;
import com.kerrykidz.system.util.DateUtil;
import com.kerrykidz.system.util.UserUtil;
import com.kerrykidz.system.vo.UserInfo;
import com.rdp.framework.core.model.MyBatisSuperModel;
import com.rdp.framework.exception.RDPException;
import com.rdp.util.GenerationUUID;
import com.rdp.util.config.PropertiesUtil;

/**
 * 会员管理控制器
 * 
 * @author YJJ
 * 
 */
@Controller
@RequestMapping("filemanagement")
public class VipController {
	private Logger loger = LoggerFactory.getLogger(VipServiceImpl.class);

	@Autowired
	private ICommonService commonService;
	@Autowired
	private IVipService vipService;
	@Autowired
	private IMemberService memberService;
	@Autowired
	private ISalesService salesService;
	@Autowired
	private IGblService gblService;
	@Autowired
	private IGuaService guaService;
	@Autowired
	private IScmInvocingProductInfoService productService;
	@Autowired
	IPaymentService paymentService;
	@Autowired
	private IMemHisService memHisService;
	@Autowired
	IOrderService orderService;
	@Autowired
	private IUserService userService;
	@Autowired
	private ISysBarCodeService sysBarCodeService;
	@Autowired
	private IScmInvocingProductInfoService scmInvocingProductInfoService;
	@Autowired
	private PosOrderEntityMapper posOrderEntityMapper;
	@Autowired
	private ICusMemClassService cusMemClassService;

	/**
	 * 跳转到会员管理页面
	 * 
	 * @param condition
	 * @param status
	 * @param birthdayStartDate
	 * @param birthdayEndDate
	 * @param joinStartDate
	 * @param joinEndDate
	 * @param invalidStartDate
	 * @param invalidEndDate
	 * @param relatedSales
	 * @return
	 * @throws RDPException
	 */
	/*
	 * @RequestMapping("/listVip") public ModelAndView listVip(
	 * 
	 * @RequestParam(value = "condition", required = false) String condition,
	 * 
	 * @RequestParam(value = "status", required = false) String status,
	 * 
	 * @RequestParam(value = "birthdayStartDate", required = false) String
	 * birthdayStartDate,
	 * 
	 * @RequestParam(value = "birthdayEndDate", required = false) String
	 * birthdayEndDate,
	 * 
	 * @RequestParam(value = "joinStartDate", required = false) String
	 * joinStartDate,
	 * 
	 * @RequestParam(value = "joinEndDate", required = false) String
	 * joinEndDate,
	 * 
	 * @RequestParam(value = "invalidStartDate", required = false) String
	 * invalidStartDate,
	 * 
	 * @RequestParam(value = "invalidEndDate", required = false) String
	 * invalidEndDate,
	 * 
	 * @RequestParam(value = "relatedSales", required = false) String
	 * relatedSales,
	 * 
	 * @RequestParam(value = "type", required = false) String type) throws
	 * RDPException { Map<String, Object> paramMap = new HashMap<String,
	 * Object>(); paramMap.put(Constants.MEMBER_CONDITION, condition);
	 * paramMap.put(Constants.MEMBER_BIRTHDAYSTARTDATE, birthdayStartDate);
	 * paramMap.put(Constants.MEMBER_BIRTHDAYENDDATE, birthdayEndDate);
	 * paramMap.put(Constants.MEMBER_JOINSTARTDATE, joinStartDate);
	 * paramMap.put(Constants.MEMBER_JOINENDDATE, joinEndDate);
	 * paramMap.put(Constants.MEMBER_INVALIDSATRTDATE, invalidStartDate);
	 * paramMap.put(Constants.MEMBER_INVALIDENDDATE, invalidEndDate);
	 * paramMap.put(Constants.MEMBER_STATUS, status);
	 * paramMap.put(Constants.MEMBER_RELATEDSALES, relatedSales);
	 * paramMap.put(Constants.MEMBER_TYPE, type); MyBatisSuperModel model = new
	 * MyBatisSuperModel(); model.setParams(paramMap); List<VipUserEntity> list
	 * = vipService.listVipUser(model); return new
	 * ModelAndView("file/file_single_x", "list", list); }
	 */

	/**
	 * 跳转到会员管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/listVip")
	public String listVip(HttpServletRequest request, HttpServletResponse response, 
			@RequestParam(value = "type", required = false) String type,
			@RequestParam(value = "indexBirth", required = false) String indexBirth,
			@RequestParam(value = "indexEndDate", required = false) String indexEndDate) {
		request.setAttribute("type", type);
		request.setAttribute("indexBirth", indexBirth);
		request.setAttribute("indexEndDate", indexEndDate);
		return "file/file_single_x";
	}

	/**
	 * 跳转到访客管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/vistor")
	public String vistor(String type, HttpServletRequest request, HttpServletResponse response) {
		request.setAttribute("type", type);
		return "file/file_visitor";
	}

	/**
	 * 跳转到非会员管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/single")
	public String single(String type, HttpServletRequest request, HttpServletResponse response) {
		request.setAttribute("type", type);
		return "file/file_single";
	}

	/**
	 * 会员管理页面Ajax视图查询
	 * 
	 * @param condition
	 * @param status
	 * @param birthdayStartDate
	 * @param birthdayEndDate
	 * @param joinStartDate
	 * @param joinEndDate
	 * @param invalidStartDate
	 * @param invalidEndDate
	 * @param payStartDate
	 * @param payEndDate
	 * @param pkUsrId
	 * @param fkBranId
	 * @return
	 */
	@RequestMapping("/listVipAjax")
	@ResponseBody
	public List<VipUserEntity> listVipAjax(
			@RequestParam(value = "condition", required = false) String condition,
			@RequestParam(value = "status", required = false) String status,
			@RequestParam(value = "birthdayStartDate", required = false) String birthdayStartDate,
			@RequestParam(value = "birthdayEndDate", required = false) String birthdayEndDate,
			@RequestParam(value = "joinStartDate", required = false) String joinStartDate,
			@RequestParam(value = "joinEndDate", required = false) String joinEndDate,
			@RequestParam(value = "invalidStartDate", required = false) String invalidStartDate,
			@RequestParam(value = "invalidEndDate", required = false) String invalidEndDate,
			@RequestParam(value = "payStartDate", required = false) String payStartDate,
			@RequestParam(value = "payEndDate", required = false) String payEndDate,
			@RequestParam(value = "pkUsrId", required = false) String pkUsrId,
			@RequestParam(value = "fkBranId", required = false) String fkBranId,
			@RequestParam(value = "type", required = false) String type,
			@RequestParam(value = "queryType", required = false) String queryType,
			@RequestParam(value = "indexBirth", required = false) String indexBirth,
			@RequestParam(value = "indexEndDate", required = false) String indexEndDate,
			HttpSession session) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put(Constants.MEMBER_CONDITION, condition);
		paramMap.put(Constants.MEMBER_BIRTHDAYSTARTDATE, birthdayStartDate);
		paramMap.put(Constants.MEMBER_BIRTHDAYENDDATE, birthdayEndDate);
		paramMap.put(Constants.MEMBER_JOINSTARTDATE, joinStartDate);
		paramMap.put(Constants.MEMBER_JOINENDDATE, joinEndDate);
		paramMap.put(Constants.MEMBER_INVALIDSATRTDATE, invalidStartDate);
		paramMap.put(Constants.MEMBER_INVALIDENDDATE, invalidEndDate);
		paramMap.put(Constants.MEMBER_PAYSTARTDATE, payStartDate);
		paramMap.put(Constants.MEMBER_PAYENDDATE, payEndDate);
		paramMap.put(Constants.MEMBER_STATUS, status);
		paramMap.put(Constants.MEMBER_PKUSRID, pkUsrId);
		paramMap.put(Constants.MEMBER_FKBRANID, fkBranId);
		paramMap.put(Constants.MEMBER_TYPE, type);
		paramMap.put(Constants.MEMBER_QUERY_TYPE, queryType);
		paramMap.put(Constants.MEMBER_INDEX_BIRTH, indexBirth);
		paramMap.put(Constants.MEMBER_INDEX_END_DATE, indexEndDate);
		MyBatisSuperModel model = new MyBatisSuperModel();
		List<VipUserEntity> list = null;
		// 判断那种类型
		if (null != condition && !"".equals(condition) && StringUtils.isNumeric(condition) == true) {
			// 号码查询
			paramMap.put(Constants.MEMBER_TELNUM, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else if (null != condition && !"".equals(condition)
				&& (condition.indexOf("@") != -1 || condition.indexOf(".") != -1)) {
			// 邮箱查询
			paramMap.put(Constants.MEMBER_EMAIL, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else {
			// 姓名查询
			model.setParams(paramMap);
			list = vipService.listVipUser(model);
		}
		return list;
	}

	/**
	 * 跳转到会员管理页面
	 * 
	 * @param condition
	 * @param status
	 * @param birthdayStartDate
	 * @param birthdayEndDate
	 * @param joinStartDate
	 * @param joinEndDate
	 * @param invalidStartDate
	 * @param invalidEndDate
	 * @param payStartDate
	 * @param payEndDate
	 * @param pkUsrId
	 * @param fkBranId
	 * @return
	 */
	@RequestMapping("/listModeVip")
	@ResponseBody
	public MyBatisSuperModel listModeVip(
			@RequestParam(value = "condition", required = false) String condition,
			@RequestParam(value = "status", required = false) String status,
			@RequestParam(value = "birthdayStartDate", required = false) String birthdayStartDate,
			@RequestParam(value = "birthdayEndDate", required = false) String birthdayEndDate,
			@RequestParam(value = "joinStartDate", required = false) String joinStartDate,
			@RequestParam(value = "joinEndDate", required = false) String joinEndDate,
			@RequestParam(value = "invalidStartDate", required = false) String invalidStartDate,
			@RequestParam(value = "invalidEndDate", required = false) String invalidEndDate,
			@RequestParam(value = "payStartDate", required = false) String payStartDate,
			@RequestParam(value = "payEndDate", required = false) String payEndDate,
			@RequestParam(value = "pkUsrId", required = false) String pkUsrId,
			@RequestParam(value = "fkBranId", required = false) String fkBranId,
			@RequestParam(value = "type", required = false) String type,
			@RequestParam(value = "queryType", required = false) String queryType,
			@RequestParam(value = "indexBirth", required = false) String indexBirth,
			@RequestParam(value = "indexEndDate", required = false) String indexEndDate,
			MyBatisSuperModel model,
			HttpSession session) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put(Constants.MEMBER_CONDITION, condition);
		paramMap.put(Constants.MEMBER_BIRTHDAYSTARTDATE, birthdayStartDate);
		paramMap.put(Constants.MEMBER_BIRTHDAYENDDATE, birthdayEndDate);
		paramMap.put(Constants.MEMBER_JOINSTARTDATE, joinStartDate);
		paramMap.put(Constants.MEMBER_JOINENDDATE, joinEndDate);
		paramMap.put(Constants.MEMBER_INVALIDSATRTDATE, invalidStartDate);
		paramMap.put(Constants.MEMBER_INVALIDENDDATE, invalidEndDate);
		paramMap.put(Constants.MEMBER_PAYSTARTDATE, payStartDate);
		paramMap.put(Constants.MEMBER_PAYENDDATE, payEndDate);
		paramMap.put(Constants.MEMBER_STATUS, status);
		paramMap.put(Constants.MEMBER_PKUSRID, pkUsrId);
		paramMap.put(Constants.MEMBER_FKBRANID, fkBranId);
		paramMap.put(Constants.MEMBER_TYPE, type);
		paramMap.put(Constants.MEMBER_QUERY_TYPE, queryType);
		paramMap.put(Constants.MEMBER_INDEX_BIRTH, indexBirth);
		paramMap.put(Constants.MEMBER_INDEX_END_DATE, indexEndDate);
		List<VipUserEntity> list = null;
		// 判断那种类型
		if (null != condition && !"".equals(condition) && StringUtils.isNumeric(condition) == true) {
			// 号码查询
			paramMap.put(Constants.MEMBER_TELNUM, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else if (null != condition && !"".equals(condition)
				&& (condition.indexOf("@") != -1 || condition.indexOf(".") != -1)) {
			// 邮箱查询
			paramMap.put(Constants.MEMBER_EMAIL, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else {
			// 姓名查询
			model.setParams(paramMap);
			list = vipService.listVipUser(model);
		}

		// 列表模式时，会员与非会员需要的商品名称
		if (type != "3") {
			String resverseType = "";
			if (type.equals(Constants.MEM_TYPE_MEMBER)) {
				resverseType = "2";// 会籍商品
			} else if (type.equals(Constants.MEM_TYPE_NOTMEMBER)) {
				resverseType = "1";// 单次票商品
			}
			if (null != list) {
				for (int i = 0; i < list.size(); i++) {
					// 查询商品名称
					VipUserEntity vipUser = list.get(i);
					if (null != vipUser.getPkMemId()) {
						StringBuffer prdNames = new StringBuffer();
						List<GblScmPrdEntity> singleTickets = scmInvocingProductInfoService.findSingleTicketByMemId(
								vipUser.getPkMemId(), resverseType);
						if (null != singleTickets) {
							for (int j = 0; j < singleTickets.size(); j++) {
								GblScmPrdEntity gblScmPrd = singleTickets.get(j);
								if (null != gblScmPrd.getPrdName()) {
									if (null == prdNames || "".equals(prdNames.toString())) {
										prdNames.append(gblScmPrd.getPrdName());
									} else {
										prdNames.append("," + gblScmPrd.getPrdName());
									}
									vipUser.setPrdName(prdNames.toString());
								}
							}
						}
					}
				}
			}
		}

		model.setResults(list);
		return model;
	}

	/**
	 * 跳转到会员详细信息页面
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/getVipUserDetail")
	@ResponseBody
	public ModelAndView getVipUserDetail(@RequestParam(value = "memberId", required = true) String memberId,
			@RequestParam(value = "type", required = true) String type,
			@RequestParam(value = "hisType", required = false) String hisType,
			@RequestParam(value = "inTime", required = false) String inTime,
			@RequestParam(value = "outTime", required = false) String outTime)
			throws RDPException {
		ModelAndView mv = new ModelAndView("file/file_single_details");
		StringBuffer memberIds = new StringBuffer();
		List<String> memberIdList = new ArrayList<String>();
		if (StringUtils.isNotBlank(memberId)) {
			// 会员、非会员信息 兄弟姐妹
			List<CusMemEntity> memList = memberService.findSiteMemberAndSiblingsById(memberId);
			mv.addObject("memList", memList);
			if (null != memList && memList.size() > 0) {
				// 放入默认会员
				mv.addObject("memberInfo", memList.get(0));
				mv.addObject("nowDate", DateUtil.formatDate("yyyy.MM.dd", new Date()));
				
				// 获取兄弟姐妹的会员Id集合
				for (int i = 0; i < memList.size(); i++) {
					CusMemEntity cusMem = memList.get(i);
					if (i == 0) {
						memberIds.append(cusMem.getPkMemId());
					} else {
						memberIds.append("," + cusMem.getPkMemId());
					}
					memberIdList.add(cusMem.getPkMemId());
					
					//判断是否停卡
					String isStopCard = "0";// 不可停卡
					List<GblScmPrdEntity> singleTickets = scmInvocingProductInfoService.findSingleTicketByMemId(cusMem.getPkMemId(), "2");
					if (null != singleTickets && singleTickets.size() > 0) {
						String prdName = singleTickets.get(0).getPrdName();
						if (prdName.contains("12")) {
							// 是12个月的会籍商品
							isStopCard = "1";// 可停卡
						}
					}
					cusMem.setIsStopCard(isStopCard);

					// 判断一起是否停过，一个会员只能停卡一次
					String isUniq = "0";// 不唯一(可停卡)
					CusMemSuspendEntity cusMemSuspend = vipService.getUniSuspendByMemberId(cusMem.getPkMemId());
					if(null!=cusMemSuspend){
						if(null==cusMemSuspend.getCancelTime()){
							isUniq = "2";// 唯一（不可停卡但可取消停卡）
						}else{
							isUniq = "1";// 唯一（不可停卡）
						}
					}else{
						isUniq = "0";// 不唯一(可停卡)
					}
					cusMem.setIsUniq(isUniq);
				}
			}
			mv.addObject("memberId", memberId);
			mv.addObject("memberIds", memberIds.toString());
			mv.addObject("type", type);
			mv.addObject("keySignFile", Constants.SYS_BASE_PATH_FETE);//放入上传路径
			
			// 获取会员有效期内停卡天数
			PropertiesUtil prop = new PropertiesUtil();
			String dayCount = prop.readSingleProps("DAY_COUNT", "/properties/kerrykidz.properties");
			mv.addObject("dayCount", dayCount);

			// 判断图片背景色
			mv.addObject("inTime", inTime);
			mv.addObject("outTime", outTime);

			// 监护人列表
			List<CusGuaEntity> guaList = memberService.findSiteGuaByMemberId(memberId);
			mv.addObject("guaList", guaList);
		}

		List<GblCusCReltypeEntity> reltypeList = memberService.findReltypes();
		mv.addObject("reltypeList", reltypeList);

		// 销售列表
		List<SecUsrEntity> salesList = userService.listUserByRoleId("106");// salesService.listSales();
		mv.addObject("salesList", salesList);

		// 国籍列表
		List<GblCusCCountryEntity> countryList = gblService.selectAll();
		mv.addObject("countryList", countryList);

		// 获取会员进出场纪录
		List<UserInOutCombEntity> inOutHisList = vipService.listVipInOutHis(memberIdList);
		if(null!=inOutHisList){
			for (int i = 0; i < inOutHisList.size(); i++) {
				UserInOutCombEntity userInOutComb=inOutHisList.get(i);
				String famBatch=userInOutComb.getFamBatch();
				Integer perCount=vipService.findCountByFambatch(famBatch);
				if(null!=perCount){
					userInOutComb.setPerCount(perCount);
				}
			}
		}
		mv.addObject("inOutHisList", inOutHisList);

		// 获取会员购票历史
		List<HisTicketEntity> hisTicketList = vipService.getBuyTicketHisList(memberIdList);
		if(null!=hisTicketList){
			//多张成人票分多条显示
			int ticketSize=hisTicketList.size();
			for (int i = 0; i < ticketSize; i++) {
				HisTicketEntity hisTicket=hisTicketList.get(i);
				if(null!=hisTicket && hisTicket.getChdCnt()==0){
					//是成人票
					Integer ticketCount=vipService.getTicketCount(hisTicket.getFkOrderId());
					if(null!=ticketCount){
						if(ticketCount>1){
							for (int j = 2; j <= ticketCount; j++) {
								hisTicketList.add(hisTicket);
							}
						}
					}
				}
			}
		}
		mv.addObject("hisTicketList", hisTicketList);

		// 获取会员消费历史
		List<HisOrderEntity> orderPayHisList = paymentService.getHisOrderEntityList(memberIdList, "!=");
		if(null!=orderPayHisList){
			//多张成人票分多条显示
			int ticketSize=orderPayHisList.size();
			for (int i = 0; i < ticketSize; i++) {
				HisOrderEntity hisOrder=orderPayHisList.get(i);
				if(null!=hisOrder && hisOrder.getChdCnt()==0){
					//是成人票
					Integer ticketCount=vipService.getTicketCount(hisOrder.getFkOrderId());
					if(null!=ticketCount){
						if(ticketCount>1){
							for (int j = 2; j <= ticketCount; j++) {
								orderPayHisList.add(hisOrder);
							}
						}
					}
				}
			}
		}
		mv.addObject("orderPayHisList", orderPayHisList);

		// 获取会员客服历史
		List<HisCarCareEntity> carCareFormHisList = memberService.getCarFormHisList(memberIdList);
		mv.addObject("carCareFormHisList", carCareFormHisList);

		// 获取会员购课历史
		//List<HisOrderEntity> buyCourseHisList = paymentService.getHisOrderEntityList(memberIdList, "=");
		List<CusMemClassEntity> buyCourseHisList = cusMemClassService.findAllMemClass(UserUtil.getUserFromSession().getBranId(), memberIdList);
		mv.addObject("buyCourseHisList", buyCourseHisList);

		// hisType判断是否购票或购买会籍
		mv.addObject("hisType", hisType);

		// 判断会籍商品是否为12个月
		// 获取商品
		/*String isStopCard = "0";// 不可停卡
		// GblScmPrdEntity gblScmPrd=vipService.getPrdByMemberId(memberId);
		List<GblScmPrdEntity> singleTickets = scmInvocingProductInfoService.findSingleTicketByMemId(memberId, "2");
		if (null != singleTickets && singleTickets.size() > 0) {
			String prdName = singleTickets.get(0).getPrdName();
			if (prdName.contains("12")) {
				// 是12个月的会籍商品
				isStopCard = "1";// 可停卡
			}
		}
		mv.addObject("isStopCard", isStopCard);

		// 判断一起是否停过，一个会员只能停卡一次
		String isUniq = "0";// 不唯一
		List<CusMemSuspendEntity> suspendList = vipService.getMemberBySuspendId(memberId);
		if (null == suspendList || suspendList.size() <= 0) {
			isUniq = "1";// 唯一
		}
		mv.addObject("isUniq", isUniq);*/

		return mv;

	}

	/**
	 * 跳转到会员详细信息页面
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/getChildInfo")
	@ResponseBody
	public ModelAndView getChildInfo(
			@RequestParam(value = "memberId", required = true) String memberId)
			throws RDPException {

		ModelAndView mv = new ModelAndView("file/file_single_details");
		// 会员、非会员信息
		CusMemEntity member = memberService.findMemberById(memberId);
		mv.addObject("memberDetail", member);
		return mv;

	}

	/**
	 * 创建会员
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "createChildInfo", method = { RequestMethod.POST })
	@ResponseBody
	public String createChildInfo(CusMemEntity memberDetail)
			throws RDPException {
		// 创建信息??缺少指纹
		vipService.createVip(memberDetail);
		return "redirect:/filemanagement/listVip.shtml";
	}

	/**
	 * 获取所有销售
	 * 
	 * @return
	 */
	@RequestMapping(value = "listSales", method = { RequestMethod.GET })
	@ResponseBody
	public List<Map<String, Object>> listSales(HttpSession session) {
		UserInfo user = UserUtil.getUserFromSession();
		List<String> roleList = user.getRoleList();
		List<SecUsrEntity> salesList = null;
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		if (null!=roleList && (roleList.get(0).equals("106") || roleList.get(0).equals("109"))) {// && roleList.size()==1
			Map<String, Object> itemMap = new HashMap<String, Object>();
			itemMap.put("pkUsrId", user.getUserId());
			itemMap.put("usrName", user.getName());
			result.add(itemMap);
		} else {
			salesList = userService.listUserByRoleId("106");// salesService.listSales();
			if (salesList != null) {
				for (int i = -1; i < salesList.size(); i++) {
					if (i == -1) {
						Map<String, Object> itemMap = new HashMap<String, Object>();
						itemMap.put("pkUsrId", "");//user.getUserId()
						itemMap.put("usrName", "全部");// user.getName()
						result.add(itemMap);
					} else {
						Map<String, Object> itemMap = new HashMap<String, Object>();
						itemMap.put("pkUsrId", salesList.get(i).getPkUsrId());
						itemMap.put("usrName", salesList.get(i).getUsrName());
						result.add(itemMap);
					}
				}
			}
		}
		return result;
	}

	/**
	 * 获取所有门店
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping(value = "listAllBran", method = { RequestMethod.GET })
	@ResponseBody
	public List<Map<String, Object>> listAllBran(HttpSession session) throws RDPException {
		UserInfo user = UserUtil.getUserFromSession();
		String abbrCode = user.getAbbrCode();
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		List<GblSecBranEntity> branList = new ArrayList<GblSecBranEntity>();
		if ("ZB".equals(abbrCode)) {
			branList = commonService.findAllBran();
			if (branList != null) {
				for (int i = 0; i < branList.size(); i++) {
					String branName = null;
					String branId = null;
					if (i == 0) {
						branName = "全部";
						branId = "";
					} else {
						branName = branList.get(i).getBranName();
						branId = branList.get(i).getPkBranId();
					}
					Map<String, Object> itemMap = new HashMap<String, Object>();
					itemMap.put("pkBranId", branId);
					itemMap.put("branName", branName);
					result.add(itemMap);
				}
			}
		} else {
			Map<String, Object> itemMap = new HashMap<String, Object>();
			itemMap.put("pkBranId", user.getBranId());
			itemMap.put("branName", user.getBranName());
			result.add(itemMap);
		}
		return result;
	}

	/**
	 * 创建监护人
	 * 
	 * @param cuardian
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "createGuardian", method = { RequestMethod.POST })
	@ResponseBody
	public String createGuardian(CusGuaEntity cuardian) throws Exception {
		// 创建监护人??缺少指纹
		vipService.createGuardian(cuardian);
		return "redirect:/filemanagement/listVip.shtml";
	}

	/**
	 * 获取监护人信息
	 * 
	 * @param memberId
	 * @param guaId
	 * @return
	 */
	@RequestMapping(value = "getGuardian")
	@ResponseBody
	public ModelAndView getGuardian(
			@RequestParam(value = "memberId", required = false) String memberId,
			@RequestParam(value = "guaId", required = false) String guaId)
			throws RDPException {
		ModelAndView mv = new ModelAndView("file/file_single_details");
		CusGuaEntity cusGua = vipService.getGuaByMemberIdAndGuaId(memberId,
				guaId);
		mv.addObject("cusGua", cusGua);
		return mv;

	}

	/**
	 * 跳转到摄像头页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "openCamera")
	public String openCamera() {
		return "file/camera";
	}

	/**
	 * 上传用户拍摄的头像
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "uploadUserImage")
	public Map<String, Object> uploadUserImage(HttpServletRequest request,
			HttpServletResponse response) {
		BufferedInputStream inputStream = null;
		FileOutputStream outputStream = null;
		try {
			UserInfo userInfo = UserUtil.getUserFromSession();
			if(null == userInfo)
			{
				return null;
			}
			String imageName = System.currentTimeMillis() + ".jpg";
			inputStream = new BufferedInputStream(request.getInputStream());
			SysParaEntity para = commonService
					.findSysParaById(Constants.SYS_BASE_PATH_IMAGE);
			String basePath = null;
			if (para != null) {
				basePath = para.getParaValue();
			}
			File f = new File(basePath);
			if (!f.exists()) {
				f.mkdirs();
			}
			outputStream = new FileOutputStream(new File(basePath + "\\"
					+ imageName));
			byte[] bytes = new byte[1024];
			int v = 0;
			while ((v = inputStream.read(bytes)) > 0) {
				outputStream.write(bytes, 0, v);
			}
			// ModelAndView mv = new ModelAndView("file/file_single_details");
			// mv.addObject("imageName",imageName);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("imageName", imageName);
			request.getSession(false).setAttribute("imageName", imageName);
			return map;
		} catch (IOException e) {
			loger.error("uploadUserImage e:" + e.getMessage());
		} catch (Exception e) {
			loger.error("uploadUserImage e:" + e.getMessage());
		} finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (Exception e) {
					loger.error("uploadUserImage e:" + e.getMessage());
				}
			}
			if (outputStream != null) {
				try {
					outputStream.close();
				} catch (Exception e) {
					loger.error("uploadUserImage e:" + e.getMessage());
				}
			}
		}
		return null;

	}

	/**
	 * 获取上传的图片名称
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "getUploadedImageName")
	public Map<String, Object> getUploadedImageName(HttpServletRequest request) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("imageName", request.getSession(false)
				.getAttribute("imageName"));
		return map;
	}

	// NEW
	/**
	 * 跳转到新建会员界面
	 * 
	 * @param cpnId
	 *            玩伴券编号
	 * @param cpnAmount
	 *            玩伴券优惠额度
	 * @return
	 */
	@RequestMapping("/jumpMemberAdd")
	public ModelAndView jumpMemberAdd(
			@RequestParam(value = "cpnId", required = false) String cpnId,
			@RequestParam(value = "cpnAmount", required = false) String cpnAmount) {
		ModelAndView mv = new ModelAndView("file/membership_add");
		if (StringUtils.isNotBlank(cpnId)) {
			mv.addObject("cpnId", cpnId);
			mv.addObject("cpnAmount", cpnAmount);
		}
		return mv;
	}

	/**
	 * 保存会员
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/saveMember")
	@ResponseBody
	public Map<String, String> saveMember(HttpSession session,
			CusMemEntity member) throws RDPException {
		Map<String, String> map = new HashMap<String, String>();
		UserInfo user = UserUtil.getUserFromSession();
		member.setFkBranId(user.getBranId());
		member.setModiBy(user.getUserId());
		if (StringUtils.isBlank(member.getPkMemId())) {
			if (memberService.checkFingerprintExist(member.getFing1()) != 0
					|| memberService.checkFingerprintExist(member.getFing2()) != 0) {
				map.put("result", Constants.FAILURE);
				map.put("message", "指纹已存在于其它用户，不可重复创建！");
				return map;
			}
			member.setStatus(Constants.MEMBER_STATUS_CREATE);
			if (StringUtils.isBlank(member.getFamilyId())) {
				String familyId = GenerationUUID.getGenerationUUID();
				member.setFamilyId(familyId);
				map.put("familyId", familyId);
			}
			vipService.createVip(member);
			map.put("memberId", member.getPkMemId());
		} else {
			vipService.updateVip(member);
			map.put("memberId", member.getPkMemId());
		}
		map.put("result", Constants.SUCCESS);
		return map;
	}

	/**
	 * 验证采集的指纹是否已存在于其它用户
	 * 
	 * @param fingerprint
	 *            指纹数据
	 * @return SUCCESS：不存在 FAILURE：已存在
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 * @date: 2014年8月22日
	 */
	@RequestMapping("/checkFingerprintExist")
	@ResponseBody
	public String checkFingerprintExist(String fingerprint)
			throws RDPException, UnsupportedEncodingException {

		if (fingerprint == null)
			return Constants.SUCCESS;
		if (memberService.checkFingerprintExist(fingerprint) != 0) {
			return Constants.FAILURE;
		}
		return Constants.SUCCESS;
	}

	/**
	 * 保存监护人
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/saveGua")
	@ResponseBody
	public Map<String, String> saveGua(CusGuaEntity gua)
			throws RDPException {
		Map<String, String> map = new HashMap<String, String>();
		UserInfo user = UserUtil.getUserFromSession();
		gua.setFkBranId(user.getBranId());
		gua.setModiBy(user.getUserId());
		if (StringUtils.isBlank(gua.getPkGuaId())) {
			if (memberService.checkFingerprintExist(gua.getFing1()) != 0
					|| memberService.checkFingerprintExist(gua.getFing2()) != 0) {
				map.put("result", Constants.FAILURE);
				map.put("message", "指纹已存在于其它用户，不可重复创建！");
				return map;
			}
			vipService.createGuardian(gua);
		} else {
			vipService.updateGuardian(gua);
		}
		map.put("result", Constants.SUCCESS);
		return map;
	}

	/**
	 * 删除会员
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/deleteMember")
	@ResponseBody
	public String deleteMember(String memberId)
			throws RDPException {
		CusMemEntity member = new CusMemEntity();
		member.setPkMemId(memberId);
		UserInfo user = UserUtil.getUserFromSession();
		member.setModiBy(user.getUserId());
		memberService.deleteMember(member);
		return Constants.SUCCESS;
	}

	/**
	 * 删除监护人
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/deleteGua")
	@ResponseBody
	public String deleteGua(String guaId)
			throws RDPException {
		CusGuaEntity gua = new CusGuaEntity();
		gua.setPkGuaId(guaId);
		UserInfo user = UserUtil.getUserFromSession();
		gua.setModiBy(user.getUserId());
		guaService.deleteGua(gua);
		return Constants.SUCCESS;
	}

	/**
	 * 根据姓名或电话号码查询会员
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/queryMember")
	@ResponseBody
	public List<CusMemEntity> queryMember(
			@RequestParam(value = "nameOrTel") String nameOrTel,
			@RequestParam(value = "cpnId", required = false) String cpnId)
			throws RDPException, UnsupportedEncodingException {
		nameOrTel = URLDecoder.decode(nameOrTel, "UTF-8");
		List<CusMemEntity> list = memberService
				.findMemberByNameOrTel(nameOrTel);
		// 有玩伴券不能在会员身上使用
		if (StringUtils.isNotBlank(cpnId) && list.size() > 0) {
			for (int i = 0; i < list.size(); i++) {
				CusMemEntity mem = list.get(i);
				if ("1".equals(mem.getMemType())) {
					list.remove(i);
					i--;
				}
			}
		}
		return list;

	}

	/**
	 * 根据指纹查询会员
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/queryMemberByFingerprint")
	@ResponseBody
	public CusMemEntity queryMemberByFingerprint(
			@RequestParam(value = "fingerprint") String fingerprint,
			@RequestParam(value = "cpnId", required = false) String cpnId)
			throws RDPException {
		Object obj = memberService.findFingerprint(fingerprint);
		if (obj instanceof CusMemEntity) {
			CusMemEntity mem = (CusMemEntity) obj;
			// 有玩伴券不能在会员身上使用
			if (StringUtils.isNotBlank(cpnId) && "1".equals(mem.getMemType())) {
				return null;
			}
			return mem;
		}
		return null;

	}

	/**
	 * 根据会员编号查询会员
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/queryMemberById")
	@ResponseBody
	public CusMemEntity queryMemberById(
			@RequestParam(value = "memberId") String memberId)
			throws RDPException {
		CusMemEntity member = memberService.findMemberById(memberId);
		return member;

	}

	/**
	 * 根据监护人编号查询监护人
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/queryGuaById")
	@ResponseBody
	public CusGuaEntity queryGuaById(@RequestParam(value = "guaId") String guaId)
			throws RDPException {
		CusGuaEntity gua = guaService.findGuaById(guaId);
		return gua;
	}

	/**
	 * 修改会员（停卡，黑名单） YJJ
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "updateMember", method = { RequestMethod.POST })
	@ResponseBody
	public String updateMember(String memberId, String status, String reason, String suspendStart,
			String suspendEnd, String mngFile)
			throws RDPException, UnsupportedEncodingException {
		if (suspendStart.contains(".")) {
			suspendStart = suspendStart.replace(".", "/");
		}
		if (suspendEnd.contains(".")) {
			suspendEnd = suspendEnd.replace(".", "/");
		}
		CusMemEntity member = memberService.findMemberById(memberId);
		member.setStatus(status);// 状态切换
		UserInfo user = UserUtil.getUserFromSession();
		member.setModiBy(user.getUserId());
		if (Constants.MEMBER_STATUS_STOPCARD.equals(member.getStatus())) {
			// 运算会员终止日期
			if (!StringUtils.isBlank(suspendStart) && !StringUtils.isBlank(suspendEnd)) {
				// 都选了
				//member.setEndDate(DateUtil.getDate(suspendStart));// 会员终止日期
				member.setEndDate(DateUtil.addDay2Date(DateUtil.getDiffDays(DateUtil.getDate(suspendStart), DateUtil.getDate(suspendEnd)), member.getEndDate()));// 会员终止日期
			} else {
				// 只选了一个
				PropertiesUtil prop = new PropertiesUtil();
				String dayCount = prop.readSingleProps("DAY_COUNT", "/properties/kerrykidz.properties");
				member.setEndDate(DateUtil.addDay2Date(Integer.parseInt(dayCount), member.getEndDate()));// 会员终止日期
			}

			member.setSuspendStart(suspendStart);
			member.setSuspendEnd(suspendEnd);
			member.setSuspendReason(reason);
			member.setFkMngFile(mngFile);// 改
		}
		if (Constants.MEMBER_STATUS_BLACK.equals(member.getStatus())) {
			member.setBlackReason(reason);
		}
		memberService.updateMember(member);
		return Constants.SUCCESS;
	}

	/**
	 * 上传
	 * 
	 * @param file
	 * @return
	 * @date: 2014年8月14日
	 */
	@RequestMapping(value = "/uploadFete")
	@ResponseBody
	public String uploadFete(MultipartFile file) {
		UserInfo userInfo = UserUtil.getUserFromSession();
		if(null == userInfo)
		{
			return null;
		}
		SysParaEntity para = commonService.findSysParaById(Constants.SYS_BASE_PATH_FETE);
		String fileName = file.getOriginalFilename();
		int index = fileName.lastIndexOf(".");
		String newFileName = System.currentTimeMillis() + (index > -1 ? fileName.substring(index) : "");
		File targetFile = new File(para.getParaValue(), newFileName);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}
		// 保存
		try {
			file.transferTo(targetFile);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}

		return newFileName;//targetFile.getPath();
	}

	/**
	 * 修改会员历史 YJJ
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/updateHisMember")
	@ResponseBody
	public String updateHisMember(String memberId, String path, String type) throws RDPException,
			UnsupportedEncodingException {
		CusMemEntity cusMem=memberService.findMemberById(memberId);
		String hisType=null;
		if(null!=cusMem.getMemType() && "1".equals(cusMem.getMemType())){
			hisType=Constants.MEM_HIS_TYPE_MEMBER;
		}else{
			hisType=Constants.MEM_HIS_TYPE_TICKET;
		}
		CusMemHisEntity cusMemHis = memHisService.findEntityByMembId(memberId, hisType);
		UserInfo user = UserUtil.getUserFromSession();
		if (null != cusMemHis) {
			cusMemHis.setModiBy(user.getUserId());
			if (("1").equals(type)) {
				// 合同路径
				cusMemHis.setContactPath(path);
			} else {
				// 免责声明路径
				cusMemHis.setDisclaimerPath(path);
			}
			memHisService.updateEntityByMembId(cusMemHis);
		} else {
			// 加入会员历史记录
			CusMemHisEntity cusMemHis2 = new CusMemHisEntity();
			cusMemHis2.setPkMemhisId(GenerationUUID.getGenerationUUID());
			cusMemHis2.setModiBy(user.getUserId());
			cusMemHis2.setFkMemId(memberId);
			if (("1").equals(type)) {
				// 合同路径
				cusMemHis2.setContactPath(path);
			} else {
				// 免责声明路径
				cusMemHis2.setDisclaimerPath(path);
			}
			memHisService.saveMemHisEntity(cusMemHis2);
		}
		return Constants.SUCCESS;
	}

	/**
	 * 更具会员ID查询余额和总额 YJJ
	 * 
	 * @return
	 * @throws RDPException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/getMemerInfo")
	@ResponseBody
	public CusMemEntity getMemerInfo(String memberId)
			throws RDPException, UnsupportedEncodingException {
		CusMemEntity member = memberService.findMemberById(memberId);
		//获取订单Id
		if(null!=member.getStatus() && ("1".equals(member.getStatus()) || "2".equals(member.getStatus()))){
			//购买过会籍或单次票的从会员历史查询
			String hisType=null;
			if(null!=member.getMemType() && "1".equals(member.getMemType())){
				hisType=Constants.MEM_HIS_TYPE_MEMBER;
			}else{
				hisType=Constants.MEM_HIS_TYPE_TICKET;
			}
			CusMemHisEntity cusMemHis=memHisService.findEntityByMembId(memberId, hisType);
			if(null!=cusMemHis && null!=cusMemHis.getFkOrderId()){
				member.setFkOrderId(cusMemHis.getFkOrderId());
			}
		}else{
			//只充值或买其他商品的
			String orderId=memHisService.findOrderByMembId(memberId);
			if(null!=orderId){
				member.setFkOrderId(orderId);
			}
		}
		return member;
	}
	
	/**
	 * 是否退单记录数
	 * @throws RDPException
	 */
	@RequestMapping("/getBackOrder")
	@ResponseBody
	public Integer getBackOrder(String memberId) throws RDPException {
		Integer backOrderCount=null;
		try {
			backOrderCount=memHisService.getBackOrderCount(memberId);
		} catch (Exception e) {
			backOrderCount=0;
		}
		return backOrderCount;
	}

	/**
	 * 充值（加订单） YJJ
	 * 
	 * @return
	 * @throws Exception
	 * @throws NumberFormatException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/recharge")
	@ResponseBody
	public String recharge(String memberId, String money, String type, @RequestParam(value = "fkOriorderId", required = false) String fkOriorderId)
			throws NumberFormatException, Exception {
		String orderId = "";
		UserInfo user = UserUtil.getUserFromSession();
		if (null != type && "1".equals(type)) {
			orderId = orderService.recharge(memberId, Double.parseDouble(money), user.getUserId(), user.getAbbrCode(), user.getBranId());
		} else if (null != type && "2".equals(type)) {
			//退款/退票
			CusMemEntity cusMem=memberService.findMemberById(memberId);
			if(null==cusMem){
				throw new Exception("memId不能为空");
			}
			
			double mony = Double.parseDouble(money);
			PosOrderEntity order = new PosOrderEntity();
			order.setRetFlag(ORDER_CONSTANTS.RET_FLAG_YES);
			order.setOrderType(ORDER_CONSTANTS.ORDER_TYPE_RECHARGE);
			order.setAmount(mony);
			order.setFkOperator(user.getUserId());
			order.setFkBranId(user.getBranId());
			order.setModiBy(user.getUserId());
			order.setCusName(cusMem.getMemName());
			order.setModiTime(new Date());
			
			//原订单id
			order.setFkOriorderId(fkOriorderId);// 待输入
			/*PosOrderEntity posOrderEntity = orderService.findOrderByPk(fkOriorderId);
			if (null != posOrderEntity) {
				order.setOrderType(posOrderEntity.getOrderType());
			}*/

			List<PosOrderPrdEntity> prds = new ArrayList<PosOrderPrdEntity>();
			PosOrderPrdEntity prd = new PosOrderPrdEntity();
			prd.setType(ORDER_CONSTANTS.ORDER_PRD_TYPE_CHARGE);
			prd.setFkMemId(memberId);
			prd.setPrice(mony);
			prd.setDisPrice(mony);
			prds.add(prd);
			
			if(null!=prds && prds.size()>0){
				orderId = this.orderService.refundGoods(order, prds, user.getAbbrCode());
			}else{
				throw new Exception("无商品信息!");
			}
		} else {
			// 假接口，现改为单独方法了
			// orderId = orderService.refundGoods(null, null, user.getUserId(),
			// user.getAbbrCode(), user.getBranId());
		}
		return orderId;
	}

	/**
	 * 续会 查询会员及其关联信息
	 * 
	 * @param memberId
	 *            会员编号
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/queryMemberDetail")
	public ModelAndView queryMemberDetail(HttpSession session,
			@RequestParam(value = "memberId", required = false) String memberId,
			@RequestParam(value = "type", required = false) String type) throws RDPException {
		ModelAndView mv = new ModelAndView("file/membership_add_x_hy");
		if (StringUtils.isNotBlank(memberId)) {
			// 会员、非会员信息 兄弟姐妹
			List<CusMemEntity> memList = memberService.findMemberAndSiblingsById(memberId);
			mv.addObject("memList", memList);
			if (memList.size() > 0) {
				mv.addObject("familyId", memList.get(0).getFamilyId());
			}
			mv.addObject("memberId", memberId);
			mv.addObject("type", type);
			// 监护人列表
			List<CusGuaEntity> guaList = memberService.findGuaByMemberId(memberId);
			mv.addObject("guaList", guaList);
		}

		List<GblCusCReltypeEntity> reltypeList = memberService.findReltypes();
		mv.addObject("reltypeList", reltypeList);

		// 会籍商品列表
		UserInfo user = UserUtil.getUserFromSession();
		GblScmPrdEntity prdEntity = new GblScmPrdEntity();
		prdEntity.setResverseType(Constants.PRODUCT_TYPE_MEMBER);
		prdEntity.setFkBranId(user.getBranId());
		List<GblScmPrdEntity> productList = productService.getProductInfo(prdEntity);
		mv.addObject("productList", productList);

		// 销售列表
		List<SecUsrEntity> salesList = userService.listUserByRoleId("106");
		mv.addObject("salesList", salesList);

		// 国籍列表
		List<GblCusCCountryEntity> countryList = gblService.selectAll();
		mv.addObject("countryList", countryList);

		return mv;
	}

	/**
	 * 根据会员查询单次票商品
	 * 
	 * @return
	 */
	@RequestMapping("/findSingleTicketByMemId")
	@ResponseBody
	public List<GblScmPrdEntity> findSingleTicketByMemId(@RequestParam(value = "pkMemId") String pkMemId) {
		List<GblScmPrdEntity> singleTickets = scmInvocingProductInfoService.findSingleTicketByMemId(pkMemId, "1");
		return singleTickets;
	}

	/**
	 * 根据会员查询单次票商品
	 * 
	 * @return
	 */
	@RequestMapping("/findAllLessonsProduct")
	@ResponseBody
	public List<GblScmPrdEntity> findAllLessonsProduct() {
		List<GblScmPrdEntity> lessonsProducts = scmInvocingProductInfoService.findAllLessonsProduct();
		return lessonsProducts;
	}

	/**
	 * 购买课程（加订单） YJJ
	 * 
	 * @return
	 * @throws Exception
	 * @throws NumberFormatException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/buyCourse")
	@ResponseBody
	public String buyCourse(HttpServletRequest request) throws NumberFormatException, Exception {
		UserInfo user = UserUtil.getUserFromSession();
		String abbrCode = user.getAbbrCode();
		String branId = user.getBranId();

		// 获取订单总额
		String infactAmountInput = request.getParameter("infactAmountInput");
		String buyCourseMemberId = request.getParameter("buyCourseMemberId");
		int tableCount = Integer.parseInt(request.getParameter("tableCount"));

		/*
		 * 先创建充值订单信息
		 */
		CusMemEntity cusMem=memberService.findMemberById(buyCourseMemberId);
		if(null==cusMem){
			throw new Exception("memId不能为空");
		}
		
		String orderId = PrimaryKeyGenerator.getPrimaryKey(BusinessType.SP, abbrCode);
		Date now = new Date();
		PosOrderEntity order = new PosOrderEntity();
		order.setPkOrderId(orderId);
		order.setOrderType(ORDER_CONSTANTS.ORDER_TYPE_BUG_COURSE);
		order.setOrderStatus(ORDER_CONSTANTS.ORDER_STATUS_NOT_PAY);
		order.setAmount(Double.parseDouble(infactAmountInput));
		order.setOperateTime(now);
		order.setFkOperator(user.getUserId());
		order.setModiBy(user.getUserId());
		order.setCusName(cusMem.getMemName());
		order.setFkBranId(branId);

		/*
		 * 创建订单商品
		 */
		List<PosOrderPrdEntity> products = new ArrayList<PosOrderPrdEntity>();
		// 加上购买课程历史记录集合
		List<CusMemClassEntity> cusMemClassList = new ArrayList<CusMemClassEntity>();
		for (int i = 0; i < tableCount; i++) {
			// 得到复选框的价格，并判断词条是否选中
			String prdPrice = request.getParameter("prdPrice" + i);
			String prdId = request.getParameter("prdId" + i);
			String startTime = request.getParameter("startTime" + i);
			String endTime = request.getParameter("endTime" + i);
			if (!StringUtils.isBlank(prdPrice)) {
				// 商品数量
				int prdCount = Integer.parseInt(request.getParameter("prdCount" + i));
				if (prdCount > 0) {
					PosOrderPrdEntity prd = new PosOrderPrdEntity();
					prd.setPkOrderId(orderId);
					prd.setFkPrdId(prdId);
					prd.setType(ORDER_CONSTANTS.ORDER_PRD_TYPE_PRODUCT);
					prd.setCount(prdCount);
					prd.setPrice(Double.parseDouble(prdPrice));
					prd.setDisPrice(Double.parseDouble(prdPrice) * prdCount);// 现不打折，如打折需乘以gbl_pos_discount
																				// 折扣价
					prd.setFkMemId(buyCourseMemberId);
					products.add(prd);

					for (int j = 1; j <= prdCount; j++) {
						CusMemClassEntity cusMemClass = new CusMemClassEntity();
						String pkMemClassId = PrimaryKeyGenerator.getPrimaryKey(BusinessType.XY, abbrCode);
						cusMemClass.setPkMemClassId(pkMemClassId);
						cusMemClass.setFkMemId(buyCourseMemberId);
						cusMemClass.setFkOrderId(orderId);
						cusMemClass.setFkPrdId(prdId);
						Date startDate;
						if (StringUtils.isBlank(startTime)) {
							startDate = null;
						} else {
							startDate = DateUtil.getDate(startTime);
						}
						Date endDate;
						if (StringUtils.isBlank(endTime)) {
							endDate = null;
						} else {
							endDate = DateUtil.getDate(endTime);
						}
						cusMemClass.setstartDate(startDate);
						cusMemClass.setendDate(endDate);
						cusMemClass.setUserdStatus("1");
						cusMemClass.setSignfilePath(null);
						cusMemClass.setModiBy(user.getUserId());
						cusMemClassList.add(cusMemClass);
					}
				}
			}
		}

		if (null!=products && products.size() > 0) {
			// 有商品
			orderId = vipService.createNotPayOfOrder(order, products, user, cusMemClassList);
		} else {
			// 无商品
			orderId = "";
		}
		return orderId;
	}

	/**
	 * 退票（加订单） YJJ
	 * 
	 * @return
	 * @throws Exception
	 * @throws NumberFormatException
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping("/refundGoods")
	@ResponseBody
	public String refundGoods(HttpServletRequest request) throws NumberFormatException, Exception {
		UserInfo user = UserUtil.getUserFromSession();

		String userId = user.getUserId();
		String abbrCode = user.getAbbrCode();
		String branId = user.getBranId();

		// 获取订单总额
		String amountTicketInput = request.getParameter("amountTicketInput");
		String returnGoodMemId = request.getParameter("returnGoodMemId");
		int liCount = Integer.parseInt(request.getParameter("liCount"));
		String fkOriorderId = request.getParameter("fkOriorderId");

		String orderId;
		/*
		 * 先创建充值订单信息
		 */
		Date now = new Date();
		PosOrderEntity order = new PosOrderEntity();

		order.setRetFlag("1");// 退单标记
		order.setFkOriorderId(fkOriorderId);// 待输入
		PosOrderEntity posOrderEntity = orderService.findOrderByPk(fkOriorderId);
		if (null != posOrderEntity) {
			order.setOrderType(posOrderEntity.getOrderType());
		}

		order.setAmount(Double.parseDouble(amountTicketInput));
		order.setOperateTime(now);
		order.setFkBranId(branId);
		order.setFkOperator(userId);

		/*
		 * 创建订单商品
		 */
		List<PosOrderPrdEntity> products = new ArrayList<PosOrderPrdEntity>();
		for (int i = 0; i < liCount; i++) {
			// 得到复选框的价格，并判断词条是否选中
			String prdPrice = request.getParameter("prdPrice" + i);
			String prdId = request.getParameter("prdId" + i);
			if (!StringUtils.isBlank(prdPrice)) {
				PosOrderPrdEntity prd = new PosOrderPrdEntity();
				prd.setFkPrdId(prdId);
				prd.setType(ORDER_CONSTANTS.ORDER_PRD_TYPE_PRODUCT);
				prd.setCount(1);
				prd.setPrice(Double.parseDouble(prdPrice));
				prd.setDisPrice(Double.parseDouble(prdPrice));
				prd.setFkMemId(returnGoodMemId);
				products.add(prd);
			}
		}

		if (products.size() > 0) {
			// 有商品
			orderId = orderService.refundGoods(order, products, abbrCode);
		} else {
			// 无商品
			orderId = "";
		}
		return orderId;
	}

	// pad for html handled
	@RequestMapping("/findVipInfo")
	public ModelAndView findVipInfo(@RequestParam(value = "indexBirth", required = false) String indexBirth, @RequestParam(value = "indexEndDate", required = false) String indexEndDate) {
		ModelAndView mav = new ModelAndView("pad/ipad_member/memberList");
		// 销售列表
		UserInfo user = UserUtil.getUserFromSession();
		List<String> roleList = user.getRoleList();
		List<SecUsrEntity> salesList = null;
		SecUsrEntity usr=new SecUsrEntity();
		if (roleList!=null && (roleList.contains("106")|| roleList!=null&&roleList.contains("109"))){
			salesList=new ArrayList<SecUsrEntity>();
			usr.setPkUsrId(user.getUserId());
			usr.setUsrName(user.getName());
			salesList.add(usr);
		} else {
			salesList = userService.listUserByRoleId("106");// salesService.listSales();
		}
		mav.addObject("indexBirth", indexBirth);
		mav.addObject("indexEndDate", indexEndDate);
		mav.addObject("salesList", salesList);
		mav.addObject("user", UserUtil.getUserFromSession());
		return mav;
	}

	/**
	 * 查询所有的会员信息for pad
	 * 
	 * @return
	 * @date: 2014年9月19日
	 */
	@RequestMapping("/listVipInfo")
	@ResponseBody
	public List<VipUserEntity> listVipInfo(@RequestParam(value = "condition", required = false) String condition,
			@RequestParam(value = "status", required = false) String status,
			@RequestParam(value = "birthdayStartDate", required = false) String birthdayStartDate,
			@RequestParam(value = "birthdayEndDate", required = false) String birthdayEndDate,
			@RequestParam(value = "joinStartDate", required = false) String joinStartDate,
			@RequestParam(value = "joinEndDate", required = false) String joinEndDate,
			@RequestParam(value = "invalidStartDate", required = false) String invalidStartDate,
			@RequestParam(value = "invalidEndDate", required = false) String invalidEndDate,
			@RequestParam(value = "payStartDate", required = false) String payStartDate,
			@RequestParam(value = "payEndDate", required = false) String payEndDate,
			@RequestParam(value = "pkUsrId", required = false) String pkUsrId,
			@RequestParam(value = "fkBranId", required = false) String fkBranId,
			@RequestParam(value = "type", required = false) String type,
			@RequestParam(value = "queryType", required = false) String queryType,
			@RequestParam(value = "indexBirth", required = false) String indexBirth,
			@RequestParam(value = "indexEndDate", required = false) String indexEndDate
			,MyBatisSuperModel model) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put(Constants.MEMBER_CONDITION, condition);
		paramMap.put(Constants.MEMBER_BIRTHDAYSTARTDATE, birthdayStartDate);
		paramMap.put(Constants.MEMBER_BIRTHDAYENDDATE, birthdayEndDate);
		paramMap.put(Constants.MEMBER_JOINSTARTDATE, joinStartDate);
		paramMap.put(Constants.MEMBER_JOINENDDATE, joinEndDate);
		paramMap.put(Constants.MEMBER_INVALIDSATRTDATE, invalidStartDate);
		paramMap.put(Constants.MEMBER_INVALIDENDDATE, invalidEndDate);
		paramMap.put(Constants.MEMBER_PAYSTARTDATE, payStartDate);
		paramMap.put(Constants.MEMBER_PAYENDDATE, payEndDate);
		paramMap.put(Constants.MEMBER_STATUS, status);
		paramMap.put(Constants.MEMBER_PKUSRID, pkUsrId);
		paramMap.put(Constants.MEMBER_FKBRANID, fkBranId);
		
		paramMap.put("memTypes", new String[]{"1","3"});
		paramMap.put(Constants.MEMBER_QUERY_TYPE, queryType);
		paramMap.put(Constants.MEMBER_INDEX_BIRTH, indexBirth);
		paramMap.put(Constants.MEMBER_INDEX_END_DATE, indexEndDate);
		List<VipUserEntity> list = null;
		// 判断那种类型
		if (null != condition && !"".equals(condition) && StringUtils.isNumeric(condition) == true) {
			// 号码查询
			paramMap.put(Constants.MEMBER_TELNUM, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else if (null != condition && !"".equals(condition)
				&& (condition.indexOf("@") != -1 || condition.indexOf(".") != -1)) {
			// 邮箱查询
			paramMap.put(Constants.MEMBER_EMAIL, condition);
			model.setParams(paramMap);
			list = vipService.findMemberByTelOrEmail(model);
		} else {
			// 姓名查询
			model.setParams(paramMap);
			list = vipService.listVipUser(model);
		}
		return list;
	}

	/**
	 * 查询会员的详细信息for pad
	 * 
	 * @return
	 * @throws RDPException
	 * @date: 2014年9月19日
	 */
	@RequestMapping("/findDetailInfo")
	public ModelAndView findDetailInfo(
			@RequestParam(value = "memberId", required = true) String memberId,
			@RequestParam(value = "type", required = true) String type,
			@RequestParam(value = "hisType", required = false) String hisType,
			@RequestParam(value = "inTime", required = false) String inTime,
			@RequestParam(value = "outTime", required = false) String outTime) throws RDPException {
		ModelAndView mav = new ModelAndView("pad/ipad_member/vipDetail");
		List<String> memberIdList = new ArrayList<String>();
		if (StringUtils.isNotBlank(memberId)) {
			// 会员、非会员信息 兄弟姐妹
			List<CusMemEntity> memList = memberService.findMemberAndSiblingsById(memberId);
			mav.addObject("memList", memList);
			if (null != memList && memList.size() > 0) {
				// 放入默认会员
				mav.addObject("memberInfo", memList.get(0));
				mav.addObject("familyId", memList.get(0).getFamilyId());

				// 获取兄弟姐妹的会员Id集合
				for (int i = 0; i < memList.size(); i++) {
					CusMemEntity cusMem = memList.get(i);
					memberIdList.add(cusMem.getPkMemId());
				}

				// 获取会员进出场纪录
				List<UserInOutCombEntity> inOutHisList = vipService.listVipInOutHis(memberIdList);
				if(null!=inOutHisList){
					for (int i = 0; i < inOutHisList.size(); i++) {
						UserInOutCombEntity userInOutComb=inOutHisList.get(i);
						String famBatch=userInOutComb.getFamBatch();
						Integer perCount=vipService.findCountByFambatch(famBatch);
						if(null!=perCount){
							userInOutComb.setPerCount(perCount);
						}
					}
				}
				mav.addObject("inOutHisList", inOutHisList);
				// 获取会员购票历史
				List<HisTicketEntity> hisTicketList = vipService.getBuyTicketHisList(memberIdList);
				mav.addObject("hisTicketList", hisTicketList);

				// 获取会员消费历史
				List<HisOrderEntity> orderPayHisList = paymentService.getHisOrderEntityList(memberIdList, "!=");
				mav.addObject("orderPayHisList", orderPayHisList);

				// 获取会员客服历史
				List<HisCarCareEntity> carCareFormHisList = memberService.getCarFormHisList(memberIdList);
				mav.addObject("carCareFormHisList", carCareFormHisList);

				// 获取会员购课历史
				List<CusMemClassEntity> buyCourseHisList = cusMemClassService.findAllMemClass(UserUtil.getUserFromSession().getBranId(), memberIdList);
				mav.addObject("buyCourseHisList", buyCourseHisList);
			}
			mav.addObject("memberId", memberId);
			mav.addObject("type", type);

			// 判断图片背景色
			mav.addObject("inTime", inTime);
			mav.addObject("outTime", outTime);

			// 监护人列表
			List<CusGuaEntity> guaList = memberService
					.findGuaByMemberId(memberId);
			mav.addObject("guaList", guaList);
		}

		List<GblCusCReltypeEntity> reltypeList = memberService.findReltypes();
		mav.addObject("reltypeList", reltypeList);

		// 销售列表
		List<SecUsrEntity> salesList = userService.listUserByRoleId("106");// salesService.listSales();
		mav.addObject("salesList", salesList);

		// 国籍列表
		List<GblCusCCountryEntity> countryList = gblService.selectAll();
		mav.addObject("countryList", countryList);

		// hisType判断是否购票或购买会籍
		mav.addObject("hisType", hisType);

		// 判断会籍商品是否为12个月
		// 获取商品
		/*String isStopCard = "0";// 不可停卡
		// GblScmPrdEntity gblScmPrd=vipService.getPrdByMemberId(memberId);
		List<GblScmPrdEntity> singleTickets = scmInvocingProductInfoService.findSingleTicketByMemId(memberId, "2");
		if (null != singleTickets && singleTickets.size() > 0) {
			String prdName = singleTickets.get(0).getPrdName();
			if (prdName.contains("12")) {
				// 是12个月的会籍商品
				isStopCard = "1";// 可停卡
			}
		}
		mav.addObject("isStopCard", isStopCard);
		// 判断一起是否停过，一个会员只能停卡一次
		String isUniq = "0";// 不唯一
		List<CusMemSuspendEntity> suspendList = vipService.getMemberBySuspendId(memberId);
		if (null == suspendList || suspendList.size() <= 0) {
			isUniq = "1";// 唯一
		}
		mav.addObject("isUniq", isUniq);*/
		return mav;
	}

	/**
	 * 获取会员购课历史
	 * 
	 * @return
	 * @throws RDPException 
	 */
	@RequestMapping("/getAjaxcourseHis")
	@ResponseBody
	public List<CusMemClassEntity> getAjaxcourseHis(@RequestParam(value = "memberId", required = false) String memberId) throws RDPException {
		String[] memberIdArray = memberId.split(",");
		List<String> memberIdList = new ArrayList<String>();
		// 获取兄弟姐妹的会员Id集合
		for (int i = 0; i < memberIdArray.length; i++) {
			String memId = memberIdArray[i];
			memberIdList.add(memId);
		}
		//List<HisOrderEntity> buyCourseHisList = paymentService.getHisOrderEntityList(memberIdList, "=");
		List<CusMemClassEntity> buyCourseHisList = cusMemClassService.findAllMemClass(UserUtil.getUserFromSession().getBranId(), memberIdList);
		return buyCourseHisList;
	}

	/**
	 * 获取上传后路径 YJJ
	 * 
	 * @return
	 * @throws Exception 
	 */
	@RequestMapping("/getFilePath")
	@ResponseBody
	public String getFilePath(String memberId, String type) throws Exception {
		String newFileName = "";
		if (!"3".equals(type)) {
			CusMemEntity member = memberService.findMemberById(memberId);
			String hisType=null;
			if(null!=member.getMemType() && "1".equals(member.getMemType())){
				hisType=Constants.MEM_HIS_TYPE_MEMBER;
			}else{
				hisType=Constants.MEM_HIS_TYPE_TICKET;
			}
			CusMemHisEntity cusMemHis = memHisService.findEntityByMembId(memberId, hisType);
			if (null != cusMemHis) {
				if ("1".equals(type)) {
					if(null!=cusMemHis.getContactPath()){
						newFileName = cusMemHis.getContactPath();
					}
				} else {
					if(null!=cusMemHis.getDisclaimerPath()){
						newFileName = cusMemHis.getDisclaimerPath();
					}
				}
			}
		} else {
			// 停卡的经理的确认件
			CusMemSuspendEntity cusMemSuspend = vipService.getUniSuspendByMemberId(memberId);
			if(null!=cusMemSuspend && null!=cusMemSuspend.getFkMngFile()){
				newFileName = cusMemSuspend.getFkMngFile();
			}
		}
		
		File targetFile=null;
		try {
			SysParaEntity para = commonService.findSysParaById(Constants.SYS_BASE_PATH_FETE);
			targetFile = new File(para.getParaValue(), newFileName);
		} catch (Exception e) {
			throw new Exception("系统参数错误!");
		}
		String filePath=targetFile.getPath();
		if(null!=filePath && filePath.indexOf(".")!=-1){
			return filePath;
		}
		return "";
	}
	
	/**
	 * 查找退会所需相关信息
	 * @param memberId
	 * @return
	 * @throws RDPException
	 * @date: 2014年9月29日
	 */
	@RequestMapping("/getRetreatMember")
	@ResponseBody
	public CusMemEntity getRetreatMember(String memberId) throws RDPException {
		CusMemEntity cusMem=memberService.getRetreatMember(memberId);
		return cusMem;
	}
	
	/**
	 * 退会下单
	 * @param memberId
	 * @return
	 * @throws Exception 
	 * @date: 2014年9月29日
	 */
	@RequestMapping("/retreatMember")
	@ResponseBody
	public String retreatMember(HttpSession session
					, @RequestParam(value="memberId") String memberId
					, @RequestParam(value="fkDisusrId") String fkDisusrId
					, @RequestParam(value="pkPrdId") String pkPrdId
					, @RequestParam(value="fkOrderId") String fkOrderId
					, @RequestParam(value="cardPrice") Double cardPrice
					, @RequestParam(value="balance") Double balance
					, @RequestParam(value="amount") Double amount) throws Exception {
		UserInfo user = UserUtil.getUserFromSession();
		
		CusMemEntity cusMem=memberService.findMemberById(memberId);
		if(null==cusMem){
			throw new Exception("memId不能为空");
		}
		
		PosOrderEntity order = new PosOrderEntity();
		// 订单类型（会籍）
		order.setOrderType(ORDER_CONSTANTS.ORDER_TYPE_VIP);
		// 退单
		order.setRetFlag(ORDER_CONSTANTS.RET_FLAG_YES);
		order.setFkOriorderId(fkOrderId);
		// 总金额
		order.setAmount(amount);
		// 下单人，关联SEC_USR表
		order.setFkOperator(user.getUserId());
		// 分店编号，关联GBL_SEC_BRAN表
		order.setFkBranId(user.getBranId());
		order.setModiBy(UserUtil.getUserFromSession().getUserId());
		order.setCusName(cusMem.getMemName());
		
		List<PosOrderPrdEntity> productList = new ArrayList<PosOrderPrdEntity>();
		PosOrderPrdEntity product = new PosOrderPrdEntity();
		// 消费类型
		product.setType(ORDER_CONSTANTS.ORDER_PRD_TYPE_PRODUCT);
		// 商品编号
		product.setFkPrdId(pkPrdId);
		// 会籍或单次票订单关联的会员非会员编号
		product.setFkMemId(memberId);
		// 排序索引
		product.setOrdIndex(0);
		// 购买数量
		product.setCount(1);
		// 商品特殊折扣授权编号(经理)
		product.setFkDisusrId(fkDisusrId);
		// 单价
		product.setPrice(cardPrice);
		// 折后单价
		product.setDisPrice(cardPrice);
		productList.add(product);

		if (balance > 0) {
			product = new PosOrderPrdEntity();
			// 消费类型（充值）
			product.setType(ORDER_CONSTANTS.ORDER_PRD_TYPE_CHARGE);
			// 会籍或单次票订单关联的会员非会员编号
			product.setFkMemId(memberId);
			// 排序索引
			product.setOrdIndex(1);
			// 购买数量
			product.setCount(1);
			// 商品特殊折扣授权编号(经理)
			product.setFkDisusrId(fkDisusrId);
			// 单价
			product.setPrice(balance);
			// 折后单价
			product.setDisPrice(balance);
			productList.add(product);
		}
		
		return orderService.refundGoods(order, productList, user.getAbbrCode());
	}
	
	/**
	 * 取消停卡YJJ
	 * 
	 * @return
	 * @throws RDPException
	 */
	@RequestMapping("/cancelStopCard")
	@ResponseBody
	public String cancelStopCard(@RequestParam(value="memberId") String memberId, @RequestParam(value="status") String status) throws RDPException {
		CusMemEntity cusMem=memberService.findMemberById(memberId);
		cusMem.setStatus(status);
		CusMemSuspendEntity cusMemSuspend=vipService.getUniSuspendByMemberId(memberId);
		if(null!=cusMemSuspend){
			cusMem.setEndDate(DateUtil.addDay2Date(-DateUtil.getDiffDays(new Date(), cusMemSuspend.getSuspendEnd()), cusMem.getEndDate()));// 会员终止日期
			memberService.cancelStopCard(cusMem, cusMemSuspend);
		}
		return Constants.SUCCESS;
	}
	
}
